/*
 * @Author: tomystery 
 * @Date: 2018-05-09 10:19:55 
 * @Last Modified by: t
 * @Last Modified time: 2018-07-15 15:51:26
 */

import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route, Redirect, Switch, Link } from 'react-router-dom';
//页面
import ProductRouter from 'page/product/router.jsx';
import Layout from 'component/layout/index.jsx';
import Home from 'page/home/index.jsx';
import Login from 'page/login/index.jsx';
import ErrorPage from 'page/error/index.jsx';
import UserList from 'page/user/index.jsx';
import OrderList from 'page/order/index.jsx';
import OrderDetail from 'page/order/detail.jsx';




class App extends React.Component {
  render() {
    let LayoutRouter = (
      <Layout>
        <Switch>
          <Route exact path='/' component={Home} />
          <Route path='/product' component={ProductRouter} />
          <Route path='/product-category' component={ProductRouter} />
          <Route path='/order' component={OrderList} />
          <Route path='/order-detail/:pid?' component={OrderDetail} />
          <Route path='/user/index' component={UserList} />
          <Redirect exact from='/user' to='/user/index' />

          <Route component={ErrorPage} /> {/* 当在/里面匹配不到其他的页面，那么就会匹配这个错误的页面，未设置path */}
        </Switch>
      </Layout>
    );


    return (
      <Router>
        <Switch>
          <Route path="/login" component={Login} />
          <Route path='/' render={props => LayoutRouter} />
        </Switch>
      </Router>
    )
  }
}
// 版权信息
const pkg = require('../package.json');
window.mmPlayer = window.mmplayer = `欢迎使用 商城后台系统!
当前版本为：V${pkg.version}
作者：ranyang`;
console.info(`%c${window.mmPlayer}`, `color:blue`);

ReactDOM.render(
  <App />,
  document.getElementById('app')
);

